

import java.util.Scanner;

//import com.sun.org.apache.bcel.internal.generic.RETURN;
//
///**
// * Created with IntelliJ IDEA.
// * Description:
// * User: 666
// * Date: 2022-11-01
// * Time: 8:57
// */
//public class Main {
//    public static void main(String[] args) {
//   pc q= new pc("傻逼","Intel",512,1024);
//   q.show1();
//    }
//}
//class Computer{
//    private String cpu;
//    private int nc;
//    private int yp;
//    public Computer(String cpu,int a,int c){
//        this.cpu=cpu;
//        this.nc=a;
//        this.yp=c;
//    }
//
//    public void setNc(int nc) {
//        this.nc = nc;
//    }
//
//    public int getNc() {
//        return nc;
//    }
//
//    public void setYp(int yp) {
//        this.yp = yp;
//    }
//
//    public int getYp() {
//        return yp;
//    }
//
//    public void setCpu(String cpu) {
//        this.cpu = cpu;
//    }
//
//    public String getCpu() {
//        return cpu;
//    }
//    public String showcom(){
//         return "cpu为 "+getCpu()+"内存= "+getNc()+"硬盘为 "+getYp();
//    }
//}
//class pc extends Computer{
//   private String brand;
//    public pc(String brand,String cpu,int cy,int yp){
//        super(cpu,cy,yp);
//        this.brand=brand;
//    }
//
//    public String getBrand() {
//        return brand;
//    }
//    public void show1(){
//        System.out.println(showcom()+"品牌为 "+brand);
//    }
//}
public class Main {
    public static void main(String[] args) {
        enum1 cd = new enum1();
        cd.enum2();
    }
}
class enum1{
    int n;
    boolean h;
    public void enum2() {
        do {
            System.out.println("************0.退出程序                ***********");
            System.out.println("************1.求三角形的周长与面积       ***********");
            System.out.println("************2.求梯形的面积              ***********");
            System.out.println("************3.求圆的周长与面积           ***********");
            Scanner s = new Scanner(System.in);
            n = s.nextInt();

            switch (n) {
                case 0:
                    break;
                case 1:
                    System.out.println("请输入三角形的边长");
                    double a = s.nextDouble();
                    double b = s.nextDouble();
                    double c = s.nextDouble();
                    Triangle T = new Triangle(a, b, c);
                    boolean f = T.show1();
                    if (f == false) {
                        System.out.println("请输入修改后的三角形边长");
                        double a1 = s.nextDouble();
                        double b2 = s.nextDouble();
                        double c2 = s.nextDouble();
                        Triangle z = new Triangle(a, b, c);
                        z.gai(a1, b2, c2);
                    }
                    break;
                case 2:
                    System.out.println("请输入梯形的边长与高");
                    double x1 = s.nextDouble();
                    double x2 = s.nextDouble();
                    double x3 = s.nextDouble();
                    Trapezium q = new Trapezium(x1, x2, x3);
                    q.show();
                    break;
                case 3:
                    System.out.println("请输入圆的半径");
                    double r = s.nextDouble();
                    Circle w = new Circle(r);
                    w.show();
                    break;
            }
        } while (n != 0);
    }
        }
class Triangle{//三角形
    Double a;
    Double b;
    Double c;
    Double longs;
    Double area;
    boolean f;
    public Triangle(double a,double b,double c){
        this.a=a;
        this.b=b;
        this.c=c;
        if(a+b>c&&a+c>b&&c+b>a) {
            this.f = true;
        }
        else
            this.f=false;
    }
public double getlong1(){
      return a+b+c;
    }
    public double getarea1(){
            double i=(a+b+c)/2;
            return Math.sqrt(i*(i-a)*(i-b)*(i-c));
}
public boolean show1(){
        if(f==true){
            System.out.println("三角形的面积为 "+getarea1()+"三角形的周长为"+getarea1());
            return true;
        }else{
            System.out.println("输入的三个边不能构成三角形，请重新输入");
return false;
        }
}
public void gai(double a,double b,double c){//修改三角形边
    this.a=a;
    this.b=b;
    this.c=c;
    if(a+b>c&&a+c>b&&c+b>a) {
        this.f = true;
    }
    else
        this.f=false;
    show1();
}
}
class Trapezium{//梯形
double a;
double b;
double h;
double area;
public Trapezium(double a,double b,double h){
    this.a=a;
    this.b=b;
    this.h=h;
}
public double getA(){
    return ((a+b)*h)/2;
    }
    public void show(){
        System.out.println("梯形面积为"+getA());
    }
}
class Circle{//圆形
double r;
double longs;
double area;
public Circle(double r){
    this.r=r;
}
    public double getLongs() {
        return Math.PI*2*r;
    }
    public double getArea() {
        return Math.PI*r*r;
    }
    public void show(){
        System.out.println("圆的周长为"+getLongs()+"圆的面积为"+getArea());
    }
}